#!/home/wcaarls/compile/bin/python

import thread, traceback

class lockdict(dict):
  def __init__(self, _dict=None):
    if _dict:
      dict.__init__(self, _dict)
    else:
      dict.__init__(self)
      
    self._lock = thread.allocate_lock()
    
  def lock(self):
    #print "l"
    #traceback.print_stack()
    self._lock.acquire()
    #print "al"
    #traceback.print_stack()
  
  def unlock(self):
    #print "ul"
    #traceback.print_stack()
    self._lock.release()

if __name__ == "__main__":
  a = lockdict()
  
  a.lock()
  a[0] = 1
  a.unlock()
  
  print a[0]
